<?php
    $_setting_user = new user_controller();
    if(isset($_POST['submit'])){
        if((!isset($_POST['acceptTerms'])) || (!validateUser($_POST['txt_username'])) || (!validatePass($_POST['txt_password'])) || (!$_setting_user->checkEmail($_POST['txt_email'])) || (!$_setting_user->checkUser($_POST['txt_username']))
        || (!$_setting_user->isValidEmail($_POST['txt_email']))){
            $_SESSION['action'] = 'registration';
        }
        else{
        $birthday = $_POST['y'] . '-' . $_POST['m'] . '-' . $_POST['d'];
        $account = new users('', $_POST['txt_username'], $_POST['txt_password'],'', '', $_POST['txt_sex'], $_POST['txt_email'], $birthday,'','', 2);
        $_setting_user->addAcount($account);
        }
    }
?>
<div id="header">
   <div id="top_header">
            <?php  if(isset($_SESSION["user"]))
                        {?>
                <!-- LEFT-HEADER -->
             <div id="top_header_1">                
                <div id="top_header_icon">
                	<div><?php include_once 'js/tweet.js'; ?></div>
                    <div style="padding-top: 3px;"><?php include_once 'js/google.js'; ?></div>
                    <div style="padding-top: 7px;"><?php include_once 'js/linked.js'; ?></div>
                    <div style="padding-top: 7px;"><?php include_once 'js/facebook.js'; ?></div>
                </div>                	
				<!-- RIGHT-HEADER -->
                <div id="top_header_right">
                    
                        <a href="views/link_direction.php?action=logout">LOG OUT</a> 
                     <?php }else{   ?>
                <div id="top_header_right">
                    <a href="views/link_direction.php?action=login">LOGIN</a> |
                    <a href="views/link_direction.php?action=registration">REGISTER</a>
                    <?php } ?>
                    
                </div>              
            </div>
            <?php 
           
            if($_SESSION['action'] == 'login') include_once 'views/login_form.php';
            elseif($_SESSION['action'] == 'registration') include_once 'views/registration_form.php';
            else { ?>
            <div id="slide_top_header">
            	
                <div id="silde_header">
	                <div id="silde_header_slide">
	                	<?php 
		                	include_once 'views/slide_show1.php';
		                ?>
	                </div>
                	<div id="silde_header_register">
	                	<?php 
	                	include_once 'views/register.php';
	                	?>
                	</div>
                </div>
            </div>
            <?php } ?>
	</div>